from pyecharts.charts import Map
from pyecharts.options import VisualMapOpts
# 构建地图对象
map_test = Map()
# 准备数据
data = [
    ("北京省",90),
    ("辽宁省",199),
    ("吉林省",80),
    ("上海省",399),
    ("陕西省",990)
]
# 添加数据
map_test.add("测试地图",data,"china")
# 设置全局选项
map_test.set_global_opts(
    visualmap_opts=VisualMapOpts(
        is_show=True,
        is_piecewise=True,
        pieces=[
            {"min":1,"max":9,"label":"1-9人","color":"#CCFFFF"},
            {"min":10,"max":99,"label":"10-99人","color":"#FFFF99"},
            {"min":100,"max":499,"label":"100-499人","color":"#FF9966"},
            {"min":499,"max":999,"label":"499-999人","color":"#FF6666"},
            {"min":1000,"max":9999,"label":"1000-9999人","color":"#CC3333"},
            {"min":10000,"label":"10000以上","color":"#990033"}
        ]
    )
)
# 绘图
map_test.render()